//
//	MVList.m
//
//	Create by mafeng on 13/8/2016
//	Copyright © 2016. All rights reserved.
//	Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport



#import "MVList.h"

NSString *const kMVListJumpurl = @"jumpurl";
NSString *const kMVListLan = @"lan";
NSString *const kMVListMvlist = @"mvlist";
NSString *const kMVListName = @"name";
NSString *const kMVListSum = @"sum";
NSString *const kMVListType = @"type";

@interface MVList ()
@end
@implementation MVList




/**
 * Instantiate the instance using the passed dictionary values to set the properties values
 */

-(instancetype)initWithDictionary:(NSDictionary *)dictionary
{
	self = [super init];
	if(![dictionary[kMVListJumpurl] isKindOfClass:[NSNull class]]){
		self.jumpurl = dictionary[kMVListJumpurl];
	}	
	if(![dictionary[kMVListLan] isKindOfClass:[NSNull class]]){
		self.lan = dictionary[kMVListLan];
	}	
	if(dictionary[kMVListMvlist] != nil && [dictionary[kMVListMvlist] isKindOfClass:[NSArray class]]){
		NSArray * mvlistDictionaries = dictionary[kMVListMvlist];
		NSMutableArray * mvlistItems = [NSMutableArray array];
		for(NSDictionary * mvlistDictionary in mvlistDictionaries){
			MVMvlist * mvlistItem = [[MVMvlist alloc] initWithDictionary:mvlistDictionary];
			[mvlistItems addObject:mvlistItem];
		}
		self.mvlist = mvlistItems;
	}
	if(![dictionary[kMVListName] isKindOfClass:[NSNull class]]){
		self.name = dictionary[kMVListName];
	}	
	if(![dictionary[kMVListSum] isKindOfClass:[NSNull class]]){
		self.sum = dictionary[kMVListSum];
	}

	if(![dictionary[kMVListType] isKindOfClass:[NSNull class]]){
		self.type = dictionary[kMVListType];
	}	
	return self;
}


/**
 * Returns all the available property values in the form of NSDictionary object where the key is the approperiate json key and the value is the value of the corresponding property
 */
-(NSDictionary *)toDictionary
{
	NSMutableDictionary * dictionary = [NSMutableDictionary dictionary];
	if(self.jumpurl != nil){
		dictionary[kMVListJumpurl] = self.jumpurl;
	}
	if(self.lan != nil){
		dictionary[kMVListLan] = self.lan;
	}
	if(self.mvlist != nil){
		NSMutableArray * dictionaryElements = [NSMutableArray array];
		for(MVMvlist * mvlistElement in self.mvlist){
			[dictionaryElements addObject:[mvlistElement toDictionary]];
		}
		dictionary[kMVListMvlist] = dictionaryElements;
	}
	if(self.name != nil){
		dictionary[kMVListName] = self.name;
	}
	dictionary[kMVListSum] = self.sum;
	if(self.type != nil){
		dictionary[kMVListType] = self.type;
	}
	return dictionary;

}

/**
 * Implementation of NSCoding encoding method
 */
/**
 * Returns all the available property values in the form of NSDictionary object where the key is the approperiate json key and the value is the value of the corresponding property
 */
- (void)encodeWithCoder:(NSCoder *)aCoder
{
	if(self.jumpurl != nil){
		[aCoder encodeObject:self.jumpurl forKey:kMVListJumpurl];
	}
	if(self.lan != nil){
		[aCoder encodeObject:self.lan forKey:kMVListLan];
	}
	if(self.mvlist != nil){
		[aCoder encodeObject:self.mvlist forKey:kMVListMvlist];
	}
	if(self.name != nil){
		[aCoder encodeObject:self.name forKey:kMVListName];
	}
	[aCoder encodeObject:self.sum forKey:kMVListSum];	if(self.type != nil){
		[aCoder encodeObject:self.type forKey:kMVListType];
	}

}

/**
 * Implementation of NSCoding initWithCoder: method
 */
- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
	self = [super init];
	self.jumpurl = [aDecoder decodeObjectForKey:kMVListJumpurl];
	self.lan = [aDecoder decodeObjectForKey:kMVListLan];
	self.mvlist = [aDecoder decodeObjectForKey:kMVListMvlist];
	self.name = [aDecoder decodeObjectForKey:kMVListName];
	self.sum = [aDecoder decodeObjectForKey:kMVListSum];
	self.type = [aDecoder decodeObjectForKey:kMVListType];
	return self;

}

/**
 * Implementation of NSCopying copyWithZone: method
 */
- (instancetype)copyWithZone:(NSZone *)zone
{
	MVList *copy = [MVList new];

	copy.jumpurl = [self.jumpurl copyWithZone:zone];
	copy.lan = [self.lan copyWithZone:zone];
	copy.mvlist = [self.mvlist copyWithZone:zone];
	copy.name = [self.name copyWithZone:zone];
	copy.sum = self.sum;
	copy.type = [self.type copyWithZone:zone];

	return copy;
}
@end
